Skip to content

fix(bindx): empty paginate body in count query (dual graphql-builder copy)#46

Merged
vparys merged 1 commit into
mainfrom
fix/count-query-empty-selection-set
Jun 17, 2026
Merged

fix(bindx): empty paginate body in count query (dual graphql-builder copy)#46
vparys merged 1 commit into
mainfrom
fix/count-query-empty-selection-set

Conversation

@vparys

@vparys vparys commented Jun 17, 2026

Copy link
Copy Markdown
Member

Problém

Standalone count query (přidaná v 0.1.42 pro total count u top-level <DataGrid>) se u některých konzumentů serializovala s prázdným tělem:

q1: paginateEducationProgram {
}

→ server vrací Syntax Error: Expected Name, found "}". List/get/mutace fungovaly.

Root cause

GraphQlQueryPrinter.processSelectionSet rozhoduje o vyrenderování pole přes node instanceof GraphQlField.

ContemberAdapter.buildCountQuery byl jediné místo, které konstruovalo selection set (pageInfo { totalCount }) přímo v balíčku @contember/bindx přes jeho vlastní import @contember/graphql-builder. Když si konzument (zde stage npicloud) v node_modules rozliší pro @contember/bindx jinou kopii @contember/graphql-builder než pro @contember/client-content (kde žije printer), instanceof selže, pole se tiše zahodí a tělo je prázdné.

List/get/mutace nebyly zasaženy, protože jejich selection sety se staví uvnitř @contember/bindx-client — tedy v kopii, kterou printer pozná.

Oprava

  • Konstrukce count selection přesunuta do @contember/bindx-client jako buildCountSelection() → všechny GraphQlField jdoucí do printeru pocházejí ze stejné kopie graphql-builderu.
  • @contember/bindx@contember/graphql-builder vůbec neimportuje (závislost odebrána) → tahle třída chyb se nemůže vrátit.
  • Přidán serializační regresní test ověřující neprázdné tělo pageInfo { totalCount }.

Test plan

  • bun run typecheck — čistý
  • bun run build — čistý
  • Nový test tests/bindx-client/countQuerySerialization.test.ts + existující tests/unit/adapter/countQuery.test.ts + tests/bindx-client/qb.test.ts — vše prochází
  • Plná sada: stejných 10 předem existujících selhání jako na main (browser testy vyžadující server + 1 form test), žádné nové

…nate body

The standalone count query (added in v0.1.42 for the top-level DataGrid total
count) was the only query whose selection set was constructed inside the
`@contember/bindx` package — `ContemberAdapter.buildCountQuery` built
`pageInfo { totalCount }` GraphQlField nodes from bindx's own
`@contember/graphql-builder` import.

The query printer (`GraphQlQueryPrinter.processSelectionSet`) decides whether
to emit a field via `node instanceof GraphQlField`. When a consumer's
node_modules resolves a different `@contember/graphql-builder` copy for
`@contember/bindx` than for `@contember/client-content`, that instanceof check
fails, the fields are silently dropped, and the query serializes to an empty
`paginate<Entity> { }` — invalid GraphQL ("Syntax Error: Expected Name,
found }"). List/get/mutation queries were unaffected because their selection
sets are all built inside `@contember/bindx-client`, matching the printer's copy.

Fix: move count selection construction into `@contember/bindx-client`
(`buildCountSelection`), so every GraphQlField flowing into the printer comes
from the same graphql-builder copy. `@contember/bindx` no longer imports
`@contember/graphql-builder` at all (dependency dropped), preventing this class
of dual-copy bug from recurring.

Adds a serialization regression test asserting the count query renders a
non-empty `pageInfo { totalCount }` body.
@vparys vparys merged commit d9de697 into main Jun 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant